package service;

import java.util.List;

import bean.GoodsRowMapper;
import bean.OrderInfo;
import bean.OrderInfoRowMapper;
import common.BaseDAO;

public class OrderInfoDAO extends BaseDAO{
	//新增一条订单记录
	public void addOrderRecord(int userid,int addressid,int payStatus,int postStatus,
			int orderstatus,int goodsNum,double totalPrice,double payPrice,
			int pointsUsed,double postFee){
		String sql="insert into order_info(userid,addressid,pay_status,post_status,"
				+ "order_status,goods_num,total_price,pay_price,points_used,post_fee"
				+ ") values(?,?,?,?,?,?,?,?,?,?)";
		this.update(sql, userid,addressid,payStatus,postStatus,
				orderstatus,goodsNum,totalPrice,payPrice,pointsUsed,postFee);
	}//values(1,1,0,0,0,3,16797.0,16597.0,0,0.0)
	
	//根据用户id查找创建时间最近的一条订单记录
	public List<OrderInfo> queryNewstByUserid(int userid){
		String sql="select * from order_info where userid=? order by create_time desc limit 1";
		return this.query(sql, new OrderInfoRowMapper(), userid);
	}
}
